from rest_framework import serializers
from goods.models import GoodsChannel, GoodsChannelGroup, GoodsCategory


# 频道管理页序列化器
class GoodsChannelsSerializers(serializers.ModelSerializer):
    group = serializers.StringRelatedField(read_only=True)
    group_id = serializers.IntegerField()
    category = serializers.StringRelatedField(read_only=True)
    category_id = serializers.IntegerField()

    class Meta:
        model = GoodsChannel
        fields = "__all__"


# 频道管理新增商品频道组序列化器
class GoodsChannelsTypesSerializers(serializers.ModelSerializer):
    class Meta:
        model = GoodsChannelGroup
        fields = "__all__"


# 频道管理新增商品一级分类序列化器
class GoodsCategoriesSerializers(serializers.ModelSerializer):

    class Meta:
        model = GoodsCategory
        fields = ("id", "name")
